You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix decodeCallToOperation() to return null for non-transferWithMemo calls instead of a lossy fabricated Tip20Operation (critical round-trip correctness fix)
Fix fromTip20Transaction() to populate operations and rawCalls separately
The PR adds smart contract call support to sdk-coin-tempo via a new RawContractCall type and addRawCall() builder method. The core approach (separating TIP-20 operations from raw contract calls, preserving calldata through round-trips, and updating verify logic) is sound. Tests are comprehensive. A few issues worth noting:
🔴 Call Order Not Preserved in Mixed Transactions
In buildImplementation, raw calls are always appended after all operations, regardless of insertion order:
So builder.addRawCall(x).addOperation(y) produces a transaction with [y, x]on-chain — not the user-specified [x, y]. For atomic batch calls where execution order matters (e.g., approve-then-mint), this silently reorders calls. The builder should maintain a single interleaved call list to preserve insertion order.
🟡 Type Safety: (recipient as any).data in verifyTransaction
if((recipientasany).data){
Using any bypasses TypeScript's type system and is fragile. Consider defining an extended recipient interface:
Or use hasOwnProperty/'data' in recipient with a type guard instead of any.
🟡 Missing Validation for RawContractCall.value
addRawCall() validates to and data, but not value. If a caller passes value: "not-a-number", BigInt("not-a-number") will throw an uncaught error at build time. Should validate with something like if (call.value !== undefined && !/^\d+$/.test(call.value)) throw ....
🟡 _inputs Excludes Raw Call Native Value
In Tip20Transaction constructor, _inputs only sums token transfer amounts:
Native ETH value in raw calls (via call.value) is not included in _inputs. This can cause accounting discrepancies when raw calls carry native value.
🟢 value: "0" vs undefined After Deserialization
When a raw call with no value (undefined) goes through a round-trip, it comes back with value: "0" (from call.value.toString() where call.value is 0n). This is harmless functionally but changes the shape of the object. Can be fixed in fromTip20Transaction by conditionally setting value only when non-zero:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket: CECHO-697
Changes